package com.efamily.ewallet.client.expense.bean;

import com.extjs.gxt.ui.client.data.BaseModelData;

public class ExpenseTypeBean extends BaseModelData {

	public ExpenseTypeBean() {

	}

	public ExpenseTypeBean(String name) {
		setName(name);
	}

	public ExpenseTypeBean(int id, String name) {
		setId(id);
		setName(name);
	}

	public String getName() {
		return get("name");
	}

	public void setName(String name) {
		set("name", name);
	}

	public int getId() {
		return get("id", -1);
	}

	public void setId(int id) {
		set("id", id);
	}

	@Override
	public String toString() {
		return getName();
	}

	@Override
	public int hashCode() {
		if (getId() != -1) {
			return getId();
		} else {
			return super.hashCode();
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (obj == this)
			return true;
		if (obj.getClass() != getClass())
			return false;
		return (((ExpenseTypeBean) obj).getId() == this.getId());
	}
}
